package
        com.zzc.fee.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.enums.SqlKeyword;
import com.hos.entity.his.CareOrderItem;
import com.hos.entity.his.CheckResult;
import com.mysql.cj.xdevapi.SqlMultiResult;
import com.zzc.fee.mapper.CheckResultMapper;
import com.zzc.fee.service.CheckResultService;
import com.zzc.fee.vo.CheckResultVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @author：xIAO_ZHOU_TX
 * @date：Created in 2023/12/22 10:42
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class CheckResultServiceImpl implements CheckResultService {
    @Resource
    private CheckResultMapper checkResultMapper;

    @Override
    public List<CheckResult> queryCheck(CheckResultVo checkResultVo) {
        LambdaQueryWrapper<CheckResult> wrapper = new LambdaQueryWrapper<>();
        // 项目名称
        if (Objects.nonNull(checkResultVo.getItemId())) {
            wrapper.eq(CheckResult::getCheckItemId, checkResultVo.getItemId());
        }
        // 患者名称
        if (StringUtils.hasText(checkResultVo.getPatientName())) {
            wrapper.like(CheckResult::getPatientName, checkResultVo.getPatientName());
        }
        // 交易时间
        if (Objects.nonNull(checkResultVo.getDateRange())) {
            wrapper.between(CheckResult::getCreateTime, checkResultVo.getDateRange()[0], checkResultVo.getDateRange()[1]);
        }

        return checkResultMapper.selectList(wrapper);
    }

    @Override
    public List<CheckResult> queryCheckStat(CheckResultVo checkResultVo) {
        List<CheckResult> checkResults = checkResultMapper.queryCheckStat(checkResultVo.getItemId(), checkResultVo.getDateRange());
        return checkResults;
    }


}